﻿Public Class Agenda_Screen

    Private _ctrl As Agenda_CTRL

    Public Sub New(ByVal ctrl As Agenda_CTRL)

        ' Cet appel est requis par le Concepteur Windows Form.
        InitializeComponent()

        ' Ajoutez une initialisation quelconque après l'appel InitializeComponent().

        _ctrl = ctrl
        RefreshListeVeto()
        With BarBouton1
            .PnlNavigation.Visible = True
            With .BtnPremier
                .Visible = True
                .Enabled = False
            End With
            With .BtnPrecedent
                .Visible = True
                .Enabled = False
            End With
            With .BtnSuivant
                .Visible = True
                .Enabled = False
            End With
            With .BtnDernier
                .Visible = True
                .Enabled = False
            End With
            With .BtnDossierMedicaux
                .Visible = True
                .Enabled = False
            End With
            With .BtnConsultation
                .Visible = True
                .Enabled = False
            End With
        End With


    End Sub

    Private Sub RefreshListeVeto()
        ChoixVetoDate1.setListeVeto = _ctrl.getListeVeto
    End Sub


    Private Sub ChoixVetoDate1_ModifSelection(ByVal sender As System.Object, ByVal e As AniForm.View.ModifSelectionEventArgs) Handles ChoixVetoDate1.ModifSelection
        If e.Veto IsNot Nothing Then
            Agenda1.DgAgenda.DataSource = _ctrl.getAgendaJour(e.Veto, e.Jour)
        End If
    End Sub

    Private Sub BarBouton1_Action(ByVal sender As Object, ByVal e As ActionEventArgs) Handles BarBouton1.Action
        Select Case e.Action
            Case actionEnum.LienConsultation
                Dim frm As New Consultation_Screen(Main_CTRL.getInstance.getConsultations_CTRL(_ctrl.agendaCourant))
                frm.ShowDialog()
            Case actionEnum.LienDossierMedical
                Dim frm As New DossierMedical_Screen(Main_CTRL.getInstance.getDossierMedical_CTRL(_ctrl.agendaCourant.Animaux))
                frm.ShowDialog()
        End Select
    End Sub

    ''' <summary>
    ''' Procèdure de controle de navigation
    ''' envoi le nouvel index au controleur en fonction du bouton cliqué
    ''' et de paramètres triviaux
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BarBouton1_Navigation(ByVal sender As Object, ByVal e As navigationEventArgs) Handles BarBouton1.Navigation
        Select Case e.navigation
            Case navigationEnum.Premier
                _ctrl.indexCourant = 0
                Agenda1.DgAgenda.Rows(_ctrl.indexCourant).Selected = True
            Case navigationEnum.Precedent
                _ctrl.indexCourant -= 1
                Agenda1.DgAgenda.Rows(_ctrl.indexCourant).Selected = True
            Case navigationEnum.Suivant
                _ctrl.indexCourant += 1
                Agenda1.DgAgenda.Rows(_ctrl.indexCourant).Selected = True
            Case navigationEnum.Dernier
                _ctrl.indexCourant = Agenda1.DgAgenda.Rows.Count - 1
                Agenda1.DgAgenda.Rows(_ctrl.indexCourant).Selected = True

        End Select
    End Sub


    Private Sub Agenda1_ChangementSelectionRDV(ByVal sender As Object, ByVal e As AgendaEventArgs) Handles Agenda1.ChangementSelectionRDV
        _ctrl.indexCourant = e.indexCourant
        _ctrl.agendaCourant = e.rdvCourant
        With BarBouton1
            .BtnPrecedent.Enabled = False
            .BtnPremier.Enabled = False
            .BtnSuivant.Enabled = False
            .BtnDernier.Enabled = False
            .BtnDossierMedicaux.Enabled = True
            .BtnConsultation.Enabled = True
            If e.indexCourant > 0 Then
                .BtnPrecedent.Enabled = True
                .BtnPremier.Enabled = True
            End If
            If e.indexCourant < e.tailleAgenda - 1 Then
                .BtnSuivant.Enabled = True
                .BtnDernier.Enabled = True
            End If
        End With


    End Sub



End Class